import json

import requests


def get_gaiaScan_data(tx_hash):
    # 交易网站的网址
    url=f'https://apis.mintscan.io/v1/cosmos/txs/{tx_hash}'

    headers = {
            'Authorization':'Bearer eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjgzLCJpYXQiOjE3MDY2MDUyMTd9.dwXu38zXIfH8qtL_hoHbOhshEJZ2zaVI7FQJPCGR-dVr6OrUXFlb76Pqu9ie8Kuopn4ohDtm_9d97wurGkF6HQ',
            'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0'
        }
    response = requests.get(url=url,headers=headers)

    if response.status_code == 200:
        print("GAIA链数据爬取完成！")
        # json_data = json.dumps(response.json(), indent=4)
        # with open('../data/gaiadata.json', 'w', encoding='utf-8') as f:
        #     f.write(json_data)
        # print(response.json())
        return response.json()
    else:

        print(f"Error: {response.status_code}, {response.text}")

# get_gaiaScan_data("C69862248D584B287C6430D6A47F2F605CE61F62B1B9C0FE95A81D22777008BA")

